/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import GUI.Admin.AdminBooking;
import GUI.Admin.AdminFilm;
import GUI.Admin.AdminFilmSchedule;
import GUI.Admin.AdminFilmType;
import GUI.Admin.AdminRoom;
import GUI.Admin.AdminSeat;
import GUI.Admin.AdminShowTimes;
import java.awt.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.jdesktop.application.SingleFrameApplication;
import utils.BusyIndicator;
import utils.StatusBar;

/**
 *
 * @author hnmtuan
 */
public class MainForm extends javax.swing.JPanel {

    SingleFrameApplication localApplication;
    BusyIndicator localBusy;
    JComponent leftPanel, topPanel, footerPanel;
    /*
     * Child panel using change
     */
    AdminBooking frmBooking;
    AdminFilm frmFilm;
    AdminFilmType frmFilmType;
    AdminRoom frmRoom;
    AdminSeat frmSeat;
    AdminShowTimes frmShowTimes;
    AdminFilmSchedule frmFilmSchedule;

    public final class ORDER_CHILDS {

        public final static int FRM_DEFAULT = -1;
        public final static int FRM_BOOKING = 1;
        public final static int FRM_FILM = 2;
        public final static int FRM_FILMTYPE = 3;
        public final static int FRM_ROOM = 4;
        public final static int FRM_SEAT = 5;
        public final static int FRM_SHOWTIMES = 6;
        public final static int FRM_FILMSCHEDULE = 7;
    }

//    private final int WIDTH_NUMS = 150;
//    private final int HEIGHT_NUMS = 150;
    private final String LOAD_CENTER_FAILED = "Load main frame failed : %s";

    public AdminFilm getFrmFilm() {
        return frmFilm;
    }

    public AdminFilmSchedule getFrmFilmSchedule() {
        return frmFilmSchedule;
    }

    public AdminBooking getFrmBooking() {
        return frmBooking;
    }

    public AdminFilmType getFrmFilmType() {
        return frmFilmType;
    }

    public AdminRoom getFrmRoom() {
        return frmRoom;
    }

    public AdminSeat getFrmSeat() {
        return frmSeat;
    }

    public AdminShowTimes getFrmShowTimes() {
        return frmShowTimes;
    }

    /**
     * Creates new form MainForm
     */
    public MainForm(SingleFrameApplication app, BusyIndicator busy) {

        this.localApplication = app;
        localBusy = busy;
        //initComponents();
        this.setLayout(new BorderLayout());
        ///////////// Header
        topPanel = new GlobalTopPanel();
        add(topPanel, BorderLayout.NORTH);
        ///////////// LeftPanel
        leftPanel = new AdminLeftPanel(this.localApplication, localBusy);
        add(leftPanel, BorderLayout.WEST);
        try {
            ///////////// RightPanel
            frmBooking = new AdminBooking(this.localApplication, localBusy);
        } catch (Exception ex) {
            frmBooking = (AdminBooking) new JPanel(new BorderLayout());
            frmBooking.removeAll();
            frmBooking.add(new JLabel(String.format(LOAD_CENTER_FAILED, ex.getMessage())));
        }
        add(frmBooking, BorderLayout.CENTER);
        ///////////// Footer
        footerPanel = new StatusBar(localApplication, localApplication.getContext().getTaskMonitor());
        add(footerPanel, BorderLayout.SOUTH);
        revalidate();

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setPreferredSize(new java.awt.Dimension(150, 150));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
